Ext.define('PHT.ConfigButton', {
    extend: 'Ext.button.Split',
    alias: ['widget.configbtn'],

    text: 'Configuration',

    initComponent: function() {
        var me = this;
        
        var checkURLwin = '';
        var checkDpropwin = '';
        var checkBatchLogwin = '';
        var errorKeyWordsCfgwin = '';

        Ext.applyIf(me, {
            menu: {
                xtype: 'menu',
                items: [
                    {
                        xtype: 'menuitem',
                        id: 'urlcfg',
                        text: 'URL Configuration',
                        handler: function(){
                        	if(!checkURLwin){
                        		checkURLwin = new PHT.CheckUrlCfgWindow();
                        	}
                    		if(checkURLwin.isVisible()){
                    			checkURLwin.hide();
                    		}else{
                    			checkURLwin.show();
                    		}
                        }
                    },
                    {
                        xtype: 'menuitem',
                        id: 'dpropcfg',
                        text: 'Dprop Check Server Configuration',
                        handler: function(){
                        	if(!checkDpropwin){
                        		checkDpropwin = new PHT.CheckDpropCfgWindow();
                        	}
                    		if(checkDpropwin.isVisible()){
                    			checkDpropwin.hide();
                    		}else{
                    			checkDpropwin.show();
                    		}
                        }
                    },
                    {
                        xtype: 'menuitem',
                        id: 'batchcfg',
                        text: 'Batch Check Configuration',
                        handler: function(){
                        	if(!checkBatchLogwin){
                        		checkBatchLogwin = new PHT.CheckBatchLogCfgWindow();
                        	}
                    		if(checkBatchLogwin.isVisible()){
                    			checkBatchLogwin.hide();
                    		}else{
                    			checkBatchLogwin.show();
                    		}
                        }
                    },
                    {
                        xtype: 'menuitem',
                        text: 'Error Key Words Configuration',
                        handler: function(){
                        	if(!errorKeyWordsCfgwin){
                        		errorKeyWordsCfgwin = new PHT.ErrorKeyWordsCfgWindow();
                        	}
                        	if(errorKeyWordsCfgwin.isVisible()){
                        		errorKeyWordsCfgwin.hide();
                    		}else{
                    			errorKeyWordsCfgwin.show();
                    		}
                        }
                    }
                ]
            }
        });

        me.callParent(arguments);
    }
});